package com.it.admin.controller;

import com.it.admin.service.AdminBlogSettingsService;
import com.it.common.aspect.ApiOperationLog;
import com.it.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.it.admin.model.dto.blogsettings.UpdateBlogSettingsDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin/blog/settings")
@Api(tags = "Admin 博客设置模块")
public class AdminBlogSettingsController {

    @Resource
    private AdminBlogSettingsService blogSettingsService;

    @PostMapping("/update")
    @ApiOperation(value = "博客基础信息修改")
    @ApiOperationLog(description = "博客基础信息修改")
    @PreAuthorize(value = "hasRole('admin')")
    public Response updateBlogSettings(@RequestBody @Validated UpdateBlogSettingsDto updateBlogSettingsDto) {

        return blogSettingsService.updateBlogSettings(updateBlogSettingsDto);
    }


    @PostMapping("/detail")
    @ApiOperation(value = "获取博客设置详情")
    @ApiOperationLog(description = "获取博客设置详情")
    public Response findDetail(){
        return blogSettingsService.findDetail();
    }

}
